package com.jie.other.compose.study03

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Checkbox
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun TaskItem(
    taskName : String,
    checkedState : Boolean,
    onCheckChange : (Boolean) -> Unit,
    closeClick : () -> Unit,
    modifier: Modifier = Modifier,
) {
    Row(
        modifier = modifier,
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Text(
            text = taskName,
            modifier = Modifier.weight(1f).padding(start = 16.dp)
        )
        Checkbox(checked = checkedState, onCheckedChange = onCheckChange)
        IconButton(onClick = closeClick) {
            Icon(imageVector = Icons.Default.Close, contentDescription = null)
        }
    }
}